package com.handu.luna.core.domain.search;

import java.io.UnsupportedEncodingException;
import java.util.Base64;

import org.apache.commons.lang.StringUtils;


public class OrderSearch {
	
	private String orderInfoNumber;
	
	private String orderusername;
	
	private String orderInfoStatus;
	
	
	private String integral;
	
	private String needShipping;
	
	private String purchasing;

	public String getOrderInfoNumber() {
		return orderInfoNumber;
	}

	public void setOrderInfoNumber(String orderInfoNumber) {
		this.orderInfoNumber = orderInfoNumber;
	}

	public String getOrderusername() {
		return orderusername;
	}

	public void setOrderusername(String orderusername) {
		this.orderusername = orderusername;
	}

	public String getOrderInfoStatus() {
		return orderInfoStatus;
	}

	public void setOrderInfoStatus(String orderInfoStatus) {
		this.orderInfoStatus = orderInfoStatus;
	}

	public String getIntegral() {
		return integral;
	}

	public void setIntegral(String integral) {
		this.integral = integral;
	}

	public String getNeedShipping() {
		return needShipping;
	}

	public void setNeedShipping(String needShipping) {
		this.needShipping = needShipping;
	}
	
	public String getPurchasing() {
		return purchasing;
	}

	public void setPurchasing(String purchasing) {
		this.purchasing = purchasing;
	}

	public  String searchUtil() throws UnsupportedEncodingException{
		StringBuffer viewState = new StringBuffer("{");
		if(StringUtils.isNotBlank(orderInfoNumber)){
			viewState.append("\"orderInfoNumber\":\""+this.orderInfoNumber+"\",");
		}
		
		if(StringUtils.isNotBlank(orderusername)){
			viewState.append("\"orderusername\":\""+this.orderusername+"\",");
		}
		
		if(StringUtils.isNotBlank(orderInfoStatus)){
			viewState.append("\"orderInfoStatus\":\""+this.orderInfoStatus+"\",");
		}
		
		if(StringUtils.isNotBlank(integral)){
			viewState.append("\"integral\":\""+integral+"\",");
		}
		
		if(StringUtils.isNotBlank(needShipping)){
			viewState.append("\"needShipping\":\""+needShipping+"\",");
		}
		
		if(StringUtils.isNotBlank(purchasing)){
			viewState.append("\"purchasing\":\""+purchasing+"\",");
		}
		
		if(viewState.length()>1){
			viewState.deleteCharAt(viewState.length()-1);
		}
		viewState.append("}");
		
		return Base64.getEncoder().encodeToString(viewState.toString().getBytes("UTF-8"));
	}
}
